home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Metrowerks CodeWarrior / Java Support / Java_Source / Java2 / src / javax / swing / JApplet.java < prev    next >
Encoding:
Java Source  |  1999-05-28  |  24.6 KB  |  803 lines  |  [TEXT/CWIE]

  1. /*
  2.  * @(#)JApplet.java    1.34 98/08/28
  3.  *
  4.  * Copyright 1997, 1998 by Sun Microsystems, Inc.,
  5.  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
  6.  * All rights reserved.
  7.  *
  8.  * This software is the confidential and proprietary information
  9.  * of Sun Microsystems, Inc. ("Confidential Information").  You
  10.  * shall not disclose such Confidential Information and shall use
  11.  * it only in accordance with the terms of the license agreement
  12.  * you entered into with Sun.
  13.  */
  14. package javax.swing;
  15.  
  16. import java.awt.*;
  17. import java.awt.event.*;
  18. import java.applet.Applet;
  19. import java.beans.PropertyChangeListener;
  20. import java.util.Locale;
  21. import java.util.Vector;
  22. import java.io.Serializable;
  23. import javax.accessibility.*;
  24.  
  25. /**
  26.  * An extended version of java.applet.Applet that adds support for 
  27.  * interposing input and painting behavior in front of the applets
  28.  * children (see glassPane), support for special children that 
  29.  * are managed by a LayeredPane (see rootPane) and for Swing MenuBars.
  30.  * <p>
  31.  * The JApplet class is slightly incompatible with java.applet.Applet.
  32.  * JApplet contains a JRootPane as it's only child.
  33.  * The <b>contentPane</b> should be the parent of any children of the JApplet.
  34.  * This is different than java.applet.Applet, e.g. to add a child to 
  35.  * an an java.applet.Applet you'd write:
  36.  * <pre>
  37.  *       applet.add(child);
  38.  * </pre>
  39.  * However using JApplet you need to add the child to the JApplet's contentPane
  40.  * instead:
  41.  * <pre>
  42.  *       applet.getContentPane().add(child);
  43.  * </pre>
  44.  * The same is true for setting LayoutManagers, removing components,
  45.  * listing children, etc. All these methods should normally be sent to
  46.  * the contentPane() instead of the JApplet itself. The contentPane() will
  47.  * always be non-null. Attempting to set it to null will cause the JApplet
  48.  * to throw an exception. The default contentPane() will have a BorderLayout
  49.  * manager set on it. 
  50.  * <p>
  51.  * Please see the JRootPane documentation for a complete description of
  52.  * the contentPane, glassPane, and layeredPane properties.
  53.  * <p>
  54.  * For the keyboard keys used by this component in the standard Look and
  55.  * Feel (L&F) renditions, see the
  56.  * <a href="doc-files/Key-Index.html#JApplet">JApplet</a> key assignments.
  57.  * <p>
  58.  * Both Netscape Communicator and Internet Explorer 4.0 unconditionally
  59.  * print an error message to the Java console when an applet attempts
  60.  * to access the AWT system event queue.  Swing applets do this once,
  61.  * to check if access is permitted.  To prevent the warning message in
  62.  * a production applet one can set a client property called 
  63.  * "defeatSystemEventQueueCheck" on the JApplets RootPane to any 
  64.  * non null value, e.g:
  65.  * <pre>
  66.  * JRootPane rp = myJApplet.getRootPane();
  67.  * rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
  68.  * </pre>
  69.  * We hope that future versions of the browsers will not have this 
  70.  * limitation and we'll be able to retire this hack.
  71.  * <p>
  72.  * <strong>Warning:</strong>
  73.  * Serialized objects of this class will not be compatible with 
  74.  * future Swing releases.  The current serialization support is appropriate
  75.  * for short term storage or RMI between applications running the same
  76.  * version of Swing.  A future release of Swing will provide support for
  77.  * long term persistence.
  78.  *
  79.  * @beaninfo
  80.  *      attribute: isContainer true
  81.  *      attribute: containerDelegate getContentPane
  82.  *    description: Swing's Applet subclass.
  83.  *
  84.  * @version 1.34 08/28/98
  85.  * @author Arnaud Weber
  86.  */
  87. public class JApplet extends Applet implements Accessible, RootPaneContainer 
  88. {
  89.     /**
  90.      * @see #getRootPane
  91.      * @see #setRootPane
  92.      */
  93.     protected JRootPane rootPane;
  94.  
  95.     /**
  96.      * @see #isRootPaneCheckingEnabled
  97.      * @see #setRootPaneCheckingEnabled
  98.      */
  99.     protected boolean rootPaneCheckingEnabled = false;
  100.  
  101.     /**
  102.      * Creates a swing applet instance.
  103.      */
  104.     public JApplet() {
  105.         super();
  106.     // Check the timerQ and restart if necessary.
  107.     TimerQueue q = TimerQueue.sharedInstance();
  108.     if(q != null) {
  109.         synchronized(q) {
  110.         if(!q.running)
  111.             q.start();
  112.         }
  113.     }
  114.  
  115.     /* Workaround for bug 4155072.  The shared double buffer image
  116.      * may hang on to a reference to this applet; unfortunately 
  117.      * Image.getGraphics() will continue to call JApplet.getForeground()
  118.      * and getBackground() even after this applet has been destroyed.
  119.      * So we ensure that these properties are non-null here.
  120.      */
  121.     setForeground(Color.black);
  122.     setBackground(Color.white);
  123.  
  124.         setLayout(new BorderLayout());
  125.         setRootPane(createRootPane());
  126.         setRootPaneCheckingEnabled(true);
  127.     }
  128.  
  129.  
  130.     /** Called by the constructor methods to create the default rootPane. */
  131.     protected JRootPane createRootPane() {
  132.         return new JRootPane();
  133.     }
  134.     
  135.     protected void processKeyEvent(KeyEvent e) {
  136.         super.processKeyEvent(e);
  137.         if(!e.isConsumed()) {
  138.             JComponent.processKeyBindingsForAllComponents(e,this,e.getID() == KeyEvent.KEY_PRESSED);
  139.         }
  140.     }
  141.  
  142.  
  143.     /** 
  144.      * Just calls <code>paint(g)</code>.  This method was overridden to 
  145.      * prevent an unneccessary call to clear the background.
  146.      */
  147.     public void update(Graphics g) {
  148.         paint(g);
  149.     }
  150.  
  151.  
  152.    /**
  153.     * Sets the menubar for this applet.
  154.     * @param menubar the menubar being placed in the applet
  155.     *
  156.     * @see #getJMenuBar
  157.     *
  158.     * @beaninfo
  159.     *      hidden: true
  160.     * description: The menubar for accessing pulldown menus from this applet.
  161.     */
  162.     public void setJMenuBar(JMenuBar menuBar) {
  163.         getRootPane().setMenuBar(menuBar);
  164.     }
  165.  
  166.    /**
  167.     * Returns the menubar set on this applet.
  168.     *
  169.     * @see #setJMenuBar
  170.     */
  171.     public JMenuBar getJMenuBar() {
  172.         return getRootPane().getMenuBar();
  173.     }
  174.  
  175.  
  176.     /**
  177.      * @return true if add and setLayout should be checked
  178.      * @see #addImpl
  179.      * @see #setLayout
  180.      * @see #setRootPaneCheckingEnabled
  181.      */
  182.     protected boolean isRootPaneCheckingEnabled() {
  183.         return rootPaneCheckingEnabled;
  184.     }
  185.  
  186.  
  187.     /**
  188.      * If true then calls to add() and setLayout() will cause an exception
  189.      * to be thrown.  
  190.      *
  191.      * @see #addImpl
  192.      * @see #setLayout
  193.      * @see #isRootPaneCheckingEnabled
  194.      */
  195.     protected void setRootPaneCheckingEnabled(boolean enabled) {
  196.         rootPaneCheckingEnabled = enabled;
  197.     }
  198.  
  199.  
  200.     /**
  201.      * Create an runtime exception with a message like:
  202.      * <pre>
  203.      * "Do not use JApplet.add() use JApplet.getContentPane().add() instead"
  204.      * </pre>
  205.      */
  206.     private Error createRootPaneException(String op) {
  207.         String type = getClass().getName();
  208.         return new Error(
  209.             "Do not use " + type + "." + op + "() use " 
  210.                           + type + ".getContentPane()." + op + "() instead");
  211.     }
  212.  
  213.  
  214.     /**
  215.      * By default, children may not be added directly to a this component,
  216.      * they must be added to its contentPane instead.  For example:
  217.      * <pre>
  218.      * thiComponent.getContentPane().add(child)
  219.      * </pre>
  220.      * An attempt to add to directly to this component will cause an
  221.      * runtime exception to be thrown.  Subclasses can disable this
  222.      * behavior.
  223.      * 
  224.      * @see #setRootPaneCheckingEnabled
  225.      * @exception Error if called with rootPaneChecking true
  226.      */
  227.     protected void addImpl(Component comp, Object constraints, int index) 
  228.     {
  229.         if(isRootPaneCheckingEnabled()) {
  230.             throw createRootPaneException("add");
  231.         }
  232.         else {
  233.             super.addImpl(comp, constraints, index);
  234.         }
  235.     }
  236.  
  237.  
  238.     /**
  239.      * By default the layout of this component may not be set,
  240.      * the layout of its contentPane should be set instead.  
  241.      * For example:
  242.      * <pre>
  243.      * thiComponent.getContentPane().setLayout(new BorderLayout())
  244.      * </pre>
  245.      * An attempt to set the layout of this component will cause an
  246.      * runtime exception to be thrown.  Subclasses can disable this
  247.      * behavior.
  248.      * 
  249.      * @see #setRootPaneCheckingEnabled
  250.      * @exception Error if called with rootPaneChecking true
  251.      */
  252.     public void setLayout(LayoutManager manager) {
  253.         if(isRootPaneCheckingEnabled()) {
  254.             throw createRootPaneException("setLayout");
  255.         }
  256.         else {
  257.             super.setLayout(manager);
  258.         }
  259.     }
  260.  
  261.  
  262.     /**
  263.      * Returns the rootPane object for this applet.
  264.      *
  265.      * @see #setRootPane
  266.      * @see RootPaneContainer#getRootPane
  267.      */
  268.     public JRootPane getRootPane() { 
  269.         return rootPane; 
  270.     }
  271.  
  272.  
  273.     /**
  274.      * Sets the rootPane property.  This method is called by the constructor.
  275.      * @param root the rootPane object for this applet
  276.      *
  277.      * @see #getRootPane
  278.      *
  279.      * @beaninfo
  280.      *   hidden: true
  281.      * description: the RootPane object for this applet.
  282.      */
  283.     protected void setRootPane(JRootPane root) {
  284.         if(rootPane != null) {
  285.             remove(rootPane);
  286.         }
  287.         rootPane = root;
  288.         if(rootPane != null) {
  289.             boolean checkingEnabled = isRootPaneCheckingEnabled();
  290.             try {
  291.                 setRootPaneCheckingEnabled(false);
  292.                 add(rootPane, BorderLayout.CENTER);
  293.             }
  294.             finally {
  295.                 setRootPaneCheckingEnabled(checkingEnabled);
  296.             }
  297.         }
  298.     }
  299.  
  300.  
  301.     /**
  302.      * Returns the contentPane object for this applet.
  303.      *
  304.      * @see #setContentPane
  305.      * @see RootPaneContainer#getContentPane
  306.      */
  307.     public Container getContentPane() { 
  308.         return getRootPane().getContentPane(); 
  309.     }
  310.  
  311.    /**
  312.      * Sets the contentPane property.  This method is called by the constructor.
  313.      * @param contentPane the contentPane object for this applet
  314.      *
  315.      * @exception java.awt.IllegalComponentStateException (a runtime
  316.      *            exception) if the content pane parameter is null
  317.      * @see #getContentPane
  318.      * @see RootPaneContainer#setContentPane
  319.      *
  320.      * @beaninfo
  321.      *     hidden: true
  322.      *     description: The client area of the applet where child 
  323.      *                  components are normally inserted.
  324.      */
  325.     public void setContentPane(Container contentPane) {
  326.         getRootPane().setContentPane(contentPane);
  327.     }
  328.  
  329.     /**
  330.      * Returns the layeredPane object for this applet.
  331.      *
  332.      * @exception java.awt.IllegalComponentStateException (a runtime
  333.      *            exception) if the layered pane parameter is null
  334.      * @see #setLayeredPane
  335.      * @see RootPaneContainer#getLayeredPane
  336.      */
  337.     public JLayeredPane getLayeredPane() { 
  338.         return getRootPane().getLayeredPane(); 
  339.     }
  340.  
  341.     /**
  342.      * Sets the layeredPane property.  This method is called by the constructor.
  343.      * @param layeredPane the layeredPane object for this applet
  344.      *
  345.      * @see #getLayeredPane
  346.      * @see RootPaneContainer#setLayeredPane
  347.      *
  348.      * @beaninfo
  349.      *     hidden: true
  350.      *     description: The pane which holds the various applet layers.
  351.      */
  352.     public void setLayeredPane(JLayeredPane layeredPane) {
  353.         getRootPane().setLayeredPane(layeredPane);
  354.     }
  355.  
  356.     /**
  357.      * Returns the glassPane object for this applet.
  358.      *
  359.      * @see #setGlassPane
  360.      * @see RootPaneContainer#getGlassPane
  361.      */
  362.     public Component getGlassPane() { 
  363.         return getRootPane().getGlassPane(); 
  364.     }
  365.  
  366.     /**
  367.      * Sets the glassPane property. 
  368.      * This method is called by the constructor.
  369.      * @param glassPane the glassPane object for this applet
  370.      *
  371.      * @see #getGlassPane
  372.      * @see RootPaneContainer#setGlassPane
  373.      *
  374.      * @beaninfo
  375.      *     hidden: true
  376.      *     description: A transparent pane used for menu rendering.
  377.      */
  378.     public void setGlassPane(Component glassPane) {
  379.         getRootPane().setGlassPane(glassPane);
  380.     }
  381.  
  382.  
  383.     /**
  384.      * Returns a string representation of this JApplet. This method 
  385.      * is intended to be used only for debugging purposes, and the 
  386.      * content and format of the returned string may vary between      
  387.      * implementations. The returned string may be empty but may not 
  388.      * be <code>null</code>.
  389.      * <P>
  390.      * Overriding paramString() to provide information about the
  391.      * specific new aspects of the JFC components.
  392.      * 
  393.      * @return  a string representation of this JApplet.
  394.      */
  395.     protected String paramString() {
  396.     String rootPaneString = (rootPane != null ?
  397.                  rootPane.toString() : "");
  398.     String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
  399.                         "true" : "false");
  400.  
  401.     return super.paramString() +
  402.     ",rootPane=" + rootPaneString +
  403.     ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
  404.     }
  405.  
  406.  
  407.  
  408. /////////////////
  409. // Accessibility support
  410. ////////////////
  411.  
  412.     protected AccessibleContext accessibleContext = null;
  413.  
  414.     /**
  415.      * Get the AccessibleContext associated with this JApplet
  416.      *
  417.      * @return the AccessibleContext of this JApplet
  418.      */
  419.     public AccessibleContext getAccessibleContext() {
  420.         if (accessibleContext == null) {
  421.             accessibleContext = new AccessibleJApplet();
  422.         }
  423.         return accessibleContext;
  424.     }
  425.  
  426.     protected class AccessibleJApplet extends AccessibleContext
  427.         implements Serializable, AccessibleComponent {
  428.  
  429.         // AccessibleContext methods
  430.         //
  431.         /**
  432.          * Get the role of this object.
  433.          *
  434.          * @return an instance of AccessibleRole describing the role of the 
  435.          * object
  436.          * @see AccessibleRole
  437.          */
  438.         public AccessibleRole getAccessibleRole() {
  439.             return AccessibleRole.FRAME;
  440.         }
  441.  
  442.         /**
  443.          * Get the state of this object.
  444.          *
  445.          * @return an instance of AccessibleStateSet containing the current 
  446.          * state set of the object
  447.          * @see AccessibleState
  448.          */
  449.         public AccessibleStateSet getAccessibleStateSet() {
  450.             AccessibleStateSet states = SwingUtilities.getAccessibleStateSet(JApplet.this);
  451.             states.add(AccessibleState.ACTIVE);
  452.             return states;
  453.         }
  454.  
  455.         /**
  456.          * Get the Accessible parent of this object.  If the parent of this
  457.          * object implements Accessible, this method should simply return
  458.          * getParent().
  459.          *
  460.          * @return the Accessible parent of this object -- can be null if this
  461.          * object does not have an Accessible parent
  462.          */
  463.         public Accessible getAccessibleParent() {
  464.         if (accessibleParent != null) {
  465.         return accessibleParent;
  466.         } else {
  467.                 Container parent = getParent();
  468.                 if (parent instanceof Accessible) {
  469.                     return (Accessible) parent;
  470.         }
  471.             }
  472.             return null;
  473.         }
  474.  
  475.         /**
  476.          * Get the index of this object in its accessible parent. 
  477.          *
  478.          * @return the index of this object in its parent; -1 if this 
  479.          * object does not have an accessible parent.
  480.          * @see #getAccessibleParent
  481.          */
  482.         public int getAccessibleIndexInParent() {
  483.             return SwingUtilities.getAccessibleIndexInParent(JApplet.this);
  484.         }
  485.  
  486.         /**
  487.          * Returns the number of accessible children in the object.  If all
  488.          * of the children of this object implement Accessible, than this
  489.          * method should return the number of children of this object.
  490.          *
  491.          * @return the number of accessible children in the object.
  492.          */
  493.         public int getAccessibleChildrenCount() {
  494.             return SwingUtilities.getAccessibleChildrenCount(JApplet.this);
  495.         }
  496.  
  497.         /**
  498.          * Return the nth Accessible child of the object.  
  499.          *
  500.          * @param i zero-based index of child
  501.          * @return the nth Accessible child of the object
  502.          */
  503.         public Accessible getAccessibleChild(int i) {
  504.             return SwingUtilities.getAccessibleChild(JApplet.this,i);
  505.         }
  506.  
  507.         /**
  508.          * Return the locale of this object.
  509.          *
  510.          * @return the locale of this object
  511.          */
  512.         public Locale getLocale() {
  513.             return JApplet.this.getLocale();
  514.         }
  515.  
  516.         /**
  517.          * Get the AccessibleComponent associated with this object if one
  518.          * exists.  Otherwise return null.
  519.          */
  520.         public AccessibleComponent getAccessibleComponent() {
  521.             return this;
  522.         }
  523.  
  524.  
  525.         // AccessibleComponent methods
  526.         //
  527.         /**
  528.          * Get the background color of this object.
  529.          *
  530.          * @return the background color, if supported, of the object; 
  531.          * otherwise, null
  532.          */
  533.         public Color getBackground() {
  534.             return JApplet.this.getBackground();
  535.         }
  536.  
  537.         /**
  538.          * Set the background color of this object.
  539.          *
  540.          * @param c the new Color for the background
  541.          */
  542.         public void setBackground(Color c) {
  543.             JApplet.this.setBackground(c);
  544.         }
  545.  
  546.         /**
  547.          * Get the foreground color of this object.
  548.          *
  549.          * @return the foreground color, if supported, of the object; 
  550.          * otherwise, null
  551.          */
  552.         public Color getForeground() {
  553.             return JApplet.this.getForeground();
  554.         }
  555.  
  556.         /**
  557.          * Set the foreground color of this object.
  558.          *
  559.          * @param c the new Color for the foreground
  560.          */
  561.         public void setForeground(Color c) {
  562.             JApplet.this.setForeground(c);
  563.         }
  564.  
  565.         /**
  566.          * Get the Cursor of this object.
  567.          *
  568.          * @return the Cursor, if supported, of the object; otherwise, null
  569.          */
  570.         public Cursor getCursor() {
  571.             return JApplet.this.getCursor();
  572.         }
  573.  
  574.         /**
  575.          * Set the Cursor of this object.
  576.          *
  577.          * @param c the new Cursor for the object
  578.          */
  579.         public void setCursor(Cursor cursor) {
  580.             JApplet.this.setCursor(cursor);
  581.         }
  582.  
  583.         /**
  584.          * Get the Font of this object.
  585.          *
  586.          * @return the Font,if supported, for the object; otherwise, null
  587.          */
  588.         public Font getFont() {
  589.             return JApplet.this.getFont();
  590.         }
  591.  
  592.         /**
  593.          * Set the Font of this object.
  594.          *
  595.          * @param f the new Font for the object
  596.          */
  597.         public void setFont(Font f) {
  598.             JApplet.this.setFont(f);
  599.         }
  600.  
  601.         /**
  602.          * Get the FontMetrics of this object.
  603.          *
  604.          * @param f the Font
  605.          * @return the FontMetrics, if supported, the object; otherwise, null
  606.          * @see getFont
  607.          */
  608.         public FontMetrics getFontMetrics(Font f) {
  609.             return JApplet.this.getFontMetrics(f);
  610.         }
  611.  
  612.         /**
  613.          * Determine if the object is enabled.
  614.          *
  615.          * @return true if object is enabled; otherwise, false
  616.          */
  617.         public boolean isEnabled() {
  618.             return JApplet.this.isEnabled();
  619.         }
  620.  
  621.         /**
  622.          * Set the enabled state of the object.
  623.          *
  624.          * @param b if true, enables this object; otherwise, disables it 
  625.          */
  626.         public void setEnabled(boolean b) {
  627.             JApplet.this.setEnabled(b);
  628.         }
  629.         
  630.         /**
  631.          * Determine if the object is visible.  Note: this means that the
  632.          * object intends to be visible; however, it may not in fact be
  633.          * showing on the screen because one of the objects that this object
  634.          * is contained by is not visible.  To determine if an object is
  635.          * showing on the screen, use isShowing().
  636.          *
  637.          * @return true if object is visible; otherwise, false
  638.          */
  639.         public boolean isVisible() {
  640.             return JApplet.this.isVisible();
  641.         }
  642.  
  643.         /**
  644.          * Set the visible state of the object.
  645.          *
  646.          * @param b if true, shows this object; otherwise, hides it 
  647.          */
  648.         public void setVisible(boolean b) {
  649.             JApplet.this.setVisible(b);
  650.         }
  651.  
  652.         /**
  653.          * Determine if the object is showing.  This is determined by checking
  654.          * the visibility of the object and ancestors of the object.  Note: 
  655.          * this will return true even if the object is obscured by another 
  656.          * (for example, it happens to be underneath a menu that was pulled 
  657.          * down).
  658.          *
  659.          * @return true if object is showing; otherwise, false
  660.          */
  661.         public boolean isShowing() {
  662.             return JApplet.this.isShowing();
  663.         }
  664.  
  665.         /** 
  666.          * Checks whether the specified point is within this object's bounds,
  667.          * where the point's x and y coordinates are defined to be relative to 
  668.          * the coordinate system of the object. 
  669.          *
  670.          * @param p the Point relative to the coordinate system of the object
  671.          * @return true if object contains Point; otherwise false
  672.          */
  673.         public boolean contains(Point p) {
  674.             return JApplet.this.contains(p);
  675.         }
  676.     
  677.         /** 
  678.          * Returns the location of the object on the screen.
  679.          *
  680.          * @return location of object on screen -- can be null if this object
  681.          * is not on the screen
  682.          */
  683.         public Point getLocationOnScreen() {
  684.             return JApplet.this.getLocationOnScreen();
  685.         }
  686.  
  687.         /** 
  688.          * Gets the location of the object relative to the parent in the form 
  689.          * of a point specifying the object's top-left corner in the screen's 
  690.          * coordinate space.
  691.          *
  692.          * @return An instance of Point representing the top-left corner of 
  693.          * the objects's bounds in the coordinate space of the screen; null if
  694.          * this object or its parent are not on the screen
  695.          */
  696.         public Point getLocation() {
  697.             return JApplet.this.getLocation();
  698.         }
  699.  
  700.         /** 
  701.          * Sets the location of the object relative to the parent.
  702.          */
  703.         public void setLocation(Point p) {
  704.             JApplet.this.setLocation(p);
  705.         }
  706.  
  707.         /** 
  708.          * Gets the bounds of this object in the form of a Rectangle object. 
  709.          * The bounds specify this object's width, height, and location
  710.          * relative to its parent. 
  711.          *
  712.          * @return A rectangle indicating this component's bounds; null if 
  713.          * this object is not on the screen.
  714.          */
  715.         public Rectangle getBounds() {
  716.             return JApplet.this.getBounds();
  717.         }
  718.  
  719.         /** 
  720.          * Sets the bounds of this object in the form of a Rectangle object. 
  721.          * The bounds specify this object's width, height, and location
  722.          * relative to its parent.
  723.          *      
  724.          * @param A rectangle indicating this component's bounds
  725.          */
  726.         public void setBounds(Rectangle r) {
  727.             JApplet.this.setBounds(r);
  728.         }
  729.  
  730.         /** 
  731.          * Returns the size of this object in the form of a Dimension object. 
  732.          * The height field of the Dimension object contains this objects's
  733.          * height, and the width field of the Dimension object contains this 
  734.          * object's width. 
  735.          *
  736.          * @return A Dimension object that indicates the size of this 
  737.          * component; null if this object is not on the screen
  738.          */
  739.         public Dimension getSize() {
  740.             return JApplet.this.getSize();
  741.         }
  742.  
  743.         /** 
  744.          * Resizes this object so that it has width width and height. 
  745.          *      
  746.          * @param d - The dimension specifying the new size of the object. 
  747.          */
  748.         public void setSize(Dimension d) {
  749.             JApplet.this.setSize(d);
  750.         }
  751.  
  752.         /**
  753.          * Returns the Accessible child, if one exists, contained at the local
  754.          * coordinate Point.
  755.          *
  756.          * @param p The point defining the top-left corner of the Accessible, 
  757.          * given in the coordinate space of the object's parent. 
  758.          * @return the Accessible, if it exists, at the specified location; 
  759.          * else null
  760.          */
  761.         public Accessible getAccessibleAt(Point p) {
  762.             return SwingUtilities.getAccessibleAt(JApplet.this,p);
  763.         }
  764.  
  765.         /**
  766.          * Returns whether this object can accept focus or not.
  767.          *
  768.          * @return true if object can accept focus; otherwise false
  769.          */
  770.         public boolean isFocusTraversable() {
  771.             return JApplet.this.isFocusTraversable();
  772.         }
  773.  
  774.         /**
  775.          * Requests focus for this object.
  776.          */
  777.         public void requestFocus() {
  778.             JApplet.this.requestFocus();
  779.         }
  780.  
  781.         /**
  782.          * Adds the specified focus listener to receive focus events from this 
  783.          * component. 
  784.          *
  785.          * @param l the focus listener
  786.          */
  787.         public void addFocusListener(FocusListener l) {
  788.             JApplet.this.addFocusListener(l);
  789.         }
  790.  
  791.         /**
  792.          * Removes the specified focus listener so it no longer receives focus 
  793.          * events from this component.
  794.          *
  795.          * @param l the focus listener
  796.          */
  797.         public void removeFocusListener(FocusListener l) {
  798.             JApplet.this.removeFocusListener(l);
  799.         }
  800.     } // inner class AccessibleJApplet
  801. }
  802.  
  803.